﻿package tools;

import java.util.Random;

public class Verification {


	public static void main(String[] args) {
		//利用汉字机内码 随机生成汉字
		String word="";
		String[] wBase={"0","1","2","3","4","5","6","7"
						,"8","9","a","b","c","d","e","f"};
		//机内码是由4个16进制数组成的
		//生成第一个机内码：
		Random r=new Random();
		int w1=r.nextInt(3)+11;
		String str_w1=wBase[w1];
		int w2;
		if(w1 == 13){
			w2 = r.nextInt(7);
		}else{
			w2 = r.nextInt(16);
		}
		String str_w2=wBase[w2];
		int w3=r.nextInt(6)+10;
		String str_w3=wBase[w3];
		int w4;
		if(w3==10){
			w4=r.nextInt(16)+1;
		}else if(w3==15){
			w4=r.nextInt(15);
		}else{
			w4=r.nextInt(16);
		}
		String str_w4=wBase[w4];
//		word=str_w1+str_w2+str_w3+str_w4;
		System.out.println(word);
		byte[] wBytes = new byte[2];
		String w12 = str_w1 + str_w2;
		int wb1=Integer.parseInt(w12, 16);
		wBytes[0]=(byte)wb1;
//		System.out.println(wb1+","+wBytes[0]);
		String w34 = str_w3 + str_w4;
		int wb2=Integer.parseInt(w34, 16);
		wBytes[1]=(byte)wb2;
//		System.out.println(wb2+","+wBytes[1]);
		word=new String(wBytes);
		System.out.println(word);

	}

}
